import Vue from 'vue'
import VueRouter from 'vue-router'
import Employment from './Employment/index'
import companyProfile from './companyProfile/index'
import legalProvisions from './legalProvisions/index'
import education from './education/index'
import activity from './activity/index'
import shop from './shop/index'
import competition from './competition/index'
import personalCenter from './personalCenter/index'
import enterpriseCenter from './enterpriseCenter/index'
import order from './order/index'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  // 首页
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/Home.vue')
  },
  // 列表
  {
    path: '/list',
    name: 'list',
    component: () => import('@/views/list.vue')
  },
  // 详情
  {
    path: '/details',
    name: 'details',
    component: () => import('@/views/details.vue')
  },
  // 就业创业
  {
    path: '/employment',
    name: 'employment',
    component: () => import('@/views/employment/employment.vue'),
    children: Employment
  },
  // 文体活动
  {
    path: '/activity',
    name: 'activity',
    component: () => import('@/views/activity/index.vue'),
    children: activity
  },
  // 康复服务
  {
    path: '/service',
    name: 'service',
    component: () => import('@/views/service/rehabilitationServices.vue')
  },
  {
    path: '/service',
    name: 'service',
    component: () => import('@/views/service/index.vue'),
    children:[
      { path: '', redirect: 'service' },
      // 康复科普列表
      {
        path: '/service/recoveryList',
        name: 'recoveryList',
        component: () => import('@/views/service/recoveryList.vue')
      },
    ]
  },
  // 机构列表
  {
    path: '/service',
    name: 'service',
    component: () => import('@/views/service/index.vue'),
    children:[
      { path: '', redirect: 'service' },
      // 机构列表
      {
        path: '/service/mechanismList',
        name: 'recoveryList',
        component: () => import('@/views/service/mechanismList.vue')
      },
    ]
  },



  // 生活维权
  {
    path: '/safeguarding',
    name: 'safeguarding',
    component: () => import('@/views/safeguarding/safeguarding.vue')
  },
  {
    path: '/safeguarding',
    name: 'safeguarding',
    component: () => import('@/views/safeguarding/index.vue'),
    children:[
      { path: '', redirect: 'safeguarding' },
      // 真实案例
      {
        path: '/safeguarding/caseList',
        name: 'caseList',
        component: () => import('@/views/safeguarding/caseList.vue')
      },
    ]
  },
  // // 真实案例
  // {
  //   path: '/safeguarding/caseList',
  //   name: 'caseList',
  //   component: () => import('@/views/safeguarding/caseList.vue')
  // },
  // 个人中心
  {
    path: '/personalCenter',
    name: 'personalCenter',
    component: () => import('@/views/my/my.vue'),
    children: personalCenter
  },
  // 企业中心
  {
    path: '/enterpriseCenter',
    name: 'enterpriseCenter',
    component: () => import('@/views/enterpriseCenter/my.vue'),
    children: enterpriseCenter
  },
  // 阳光商城
  {
    path: '/shop',
    name: 'shop',
    component: () => import('@/views/shopping/index.vue'),
    children: shop
  },
  // 公司概况
  {
    path: '/companyProfile',
    name: 'companyProfile',
    component: () => import('@/views/companyProfile/index.vue'),
    // children: companyProfile
  },
  // 法律声明
  {
    path: '/legalProvisions',
    name: 'legalProvisions',
    component: () => import('@/views/legalProvisions/index.vue'),
    children: legalProvisions
  },
  //教育培训首页
  {
    path: '/education',
    name: 'education',
    component: () => import('@/views/education/index.vue'),
    children: education
  },
  // 订单与发票
  {
    path: '/order',
    name: 'order',
    component: () => import('@/views/order/index.vue'),
    children: order
  },
  // 文章详情页
  {
    path: '/details/details',
    name: 'details',
    component: () => import('@/views/details.vue')
  },
  // 专栏列表页
  {
    path: '/all/specialColumn',
    name: 'specialColumn',
    component: () => import('@/views/all/specialColumn.vue')
  },
  // 活动详情页
  // {
  //   path: '/activity/activityDetails',
  //   component: () => import('@/views/activity/activityDetails.vue')
  // },
  // 我的简历
  {
    path: '/MyResume',
    name: 'MyResume',
    component: () => import('@/views/MyResume/index.vue')
  },
  // 服务条款
  {
    name: 'TermsOfService',
    path: '/TermsOfService',
    component: () => import('@/views/all/TermsOfService.vue')
  },
  // 新闻列表
  {
    path: '/NewsList',
    name: 'NewsList',
    component: () => import('@/views/all/newsList.vue')
  },
  // 通知公告列表列表
  {
    path: '/noticeList',
    name: 'noticeList',
    component: () => import('@/views/all/noticeList.vue')
  },
  {
    path: '/competition',
    name: 'competition',
    component: () => import('@/views/competition/index.vue'),
    children: competition
  },
  // 404页面
  {
    path: '*',
    component: () => import('@/views/error.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, saveTop) { if (saveTop) { return saveTop; } else { return { x: 0, y: 0 } } },
})

export default router
